export default {
  namespaced: true,
  state: {
    isShowToast: false,
    toastMsg: "",
    toastType: "",
  },

  mutations: {
    changeIsShowToast(state, payload) {
      state.isShowToast = payload.isShow;
      // 提示框显示才执行这个
      if (payload.isShow) {
        state.toastMsg = payload.msg;
        state.toastType = payload.type;
      }
    },
  },
  actions: {
    asyncChangeIsShowToast({ commit }, payload) {
      // 触发同步事件
      commit("changeIsShowToast", payload);
      // 过一段时间自动-关闭提示
      setTimeout(() => {
        commit("changeIsShowToast", { isShow: false });
      }, 2000);
    },
  },
};
